home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / mutt / me2s_pl7.zoo / mu_edit2 / ed / getkey.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-05  |  1.9 KB  |  65 lines

  1. static char rcsid[] = "$Id: getkey.c,v 1.2 1992/11/10 20:02:34 mike Exp $";
  2.  
  3. /* $Log: getkey.c,v $
  4.  * Revision 1.2  1992/11/10  20:02:34  mike
  5.  * - Changed `getkey' for the Atari GEM version.
  6.  *
  7.  * Revision 1.1  1992/09/14  13:02:14  mike
  8.  * Initial revision
  9.  *
  10.  */
  11.  
  12. /* getkey.c : get a keycode from the <key device>
  13.  * C Durland
  14.  */
  15.  
  16. /* Copyright 1990, 1991 Craig Durland
  17.  *   Distributed under the terms of the GNU General Public License.
  18.  *   Distributed "as is", without warranties of any kind, but comments,
  19.  *     suggestions and bug reports are welcome.
  20.  */
  21.  
  22. #include <const.h>
  23. #include <char.h>
  24. #include "ed.h"
  25. #include "../me2/stio.h"
  26.  
  27. KeyCode Eprefixes[] = { META, PFIX1, PFIX2, PFIX3 };
  28.  
  29.     /* Ectok(kc,part2) : character to keycode
  30.      *   kc : keycode to convert
  31.      *   part2: TRUE if kc might be part2 of prefixed ME key
  32.      *     (eg in "ESC a" => ctok(a,TRUE) because second part of prefixed
  33.      *     keys are always uppercase.  "SOFKEY a" => ktoc(a,FALSE) because
  34.      *     softkeys get the whole keymap.  Prefix keys are listed in table
  35.      *     above.)
  36.      */
  37. KeyCode Ectok(kc,part2) register KeyCode kc; register int part2;
  38. {
  39.   if ((kc & 0xFF00) == 0)    /* Only munge it if its not already a KeyCode */
  40.   {
  41.     if (part2) kc = toupper(kc);        /* Force to uppercase */
  42.     if (iscntrl(kc)) kc = CTRL | (kc ^ 0x40);    /* control a -> C-A */
  43.   }
  44.   return kc;
  45. }
  46.  
  47. /* Read in a key.
  48.  * Do the standard keyboard preprocessing.
  49.  * Convert the keys to the internal character set.
  50.  */
  51. KeyCode Eget_key(pkeys,key)
  52. PKey *pkeys;
  53. int key;    /* Value from evnt_keybd call or 0.    */
  54. {
  55.   register KeyCode kc;
  56.   register int j;
  57.  
  58.   Cursor_on();
  59.   kc = Ectok(t_getcharX(key),FALSE);
  60.   Cursor_off();
  61.   for (j = PKEYS; j--; )    /* check for prefix keys */
  62.     if (kc == pkeys[j]) return Eprefixes[j] | Ectok(t_getcharX(0),TRUE);
  63.   return kc;
  64. }
  65.